/**
* This is about <code>PlaneTest</code>.
* {@link www.hyperfiction.fr}
* @author shoe[box]
*/

package {
	import org.shoebox.guacamole.materials.ColorMaterial;
	import org.shoebox.guacamole.materials.BitmapMaterial;
	import org.shoebox.guacamole.view.containers.GuaContainer;
	[SWF(backgroundColor="#ABABAB", frameRate="60", width="1000", height="700")]
	
	import org.shoebox.guacamole.assets.AssetManager;
	import org.shoebox.guacamole.view.GuaSprite;
	import org.shoebox.utils.logger.Logger;
	import flash.events.Event;
	
	/**
	* PlaneTest
	* @author shoebox
	*/
	public class PlaneTest extends BasicTest{
		
		protected var _oMat				: BitmapMaterial;
		protected var _oContainer		: GuaContainer;
		protected var _oPlane			: GuaSprite;
		protected var _vPlane			: Vector.<GuaSprite>;
		
		// -------o constructor
		
			/**
			* Constructor of the PlaneTest class
			*
			* @public
			* @return	void
			*/
			public function PlaneTest() : void {
				super( );
			}

		// -------o public
				
			/**
			* addModels function
			* @public
			* @param 
			* @return
			*/
			final override public function addModels() : void {
				
				_oCam.setNearFar( -200 , 200 );
				
				_oContainer = new GuaContainer( );
				_oContainer.setScale( 1 , 1 );
				_oScene.addChild( _oContainer );
				
				_vPlane = new Vector.<GuaSprite>( );
				_oMat = AssetManager.getBitmapMaterial( new _mole( ) );
				
				var dx : int = 0;
				var dy : int = 0;
				for( dy ; dy < 4 ; dy++ ){
					dx = 0;
					for( dx ; dx < 7 ; dx++ ){
						_addPlane( dx , dy );
					}
				}
				
			}	
			
		// -------o protected

			/**
			* 
			*
			* @param 
			* @return
			*/
			final protected function _addPlane( dx : int , dy : int ) : GuaSprite {
				
				var oCol : ColorMaterial = new ColorMaterial( );
					oCol.color = 0xFF6600;
					oCol.refScene = _oScene;
					
				var p : GuaSprite = new GuaSprite( 128 , 128 , _oMat , 1 , 1 );
					p.setPivot( 64 , 64 );
					p.x = dx * 140 + 15;
					p.y = dy * 140 + 50;
					p.z = 100;
				_oScene.addChild( p );
				_vPlane.push( p );
				return p;
			}

			/**
			* 
			*
			* @param 
			* @return
			*/
			final override protected function _onFrame( e : Event ) : void {
				
				var g : GuaSprite;
				for each( g in _vPlane )
					g.rotate( 2 , 3 , 4 );
				
				super._onFrame( e );
			}

		// -------o misc

			public static function trc(...args : *) : void {
				Logger.log(PlaneTest, args);
			}
	}
}
